/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * dbEditor.java
 *
 * Created on 26/08/2011, 19:34:20
 */
package drecker.dbeditor.front_end;

import fallen.deck.entity.*;
import fallen.deck.hibernate.Queries;
import java.awt.Color;
import java.awt.HeadlessException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import csm.uttils.generics.GenericTableModel;
import java.awt.Cursor;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Iterator;

import csm.uttils.Archive;

/**
 *
 * @author Carlos S. Moreno <CarlosS.Moreno@gmail.com>
 */
public class dbEditor extends javax.swing.JFrame {

    private HashMap<String, Expansion> expansions = new HashMap<String, Expansion>();
    private HashMap<String, Type> types = new HashMap<String, Type>();
    private HashMap<String, Pathway> pathways = new HashMap<String, Pathway>();
    private HashMap<String, Frequency> frequencies = new HashMap<String, Frequency>();
    private HashMap<String, Artist> artists = new HashMap<String, Artist>();
    private HashMap<String, Subtype> subtypes = new HashMap<String, Subtype>();
    private HashMap<String, Supertype> supertypes = new HashMap<String, Supertype>();

    /** Creates new form dbEditor */
    public dbEditor() {
        initComponents();
        //loadCombos();
        //loadLists();  
        //loadTable();
    }

    private void checkDataBase() {
        //if (Queries.getExpansions().size() == 0)
        //drecker.dbeditor.DB_Init.resetDataBase();
    }

    public void loadTable() {
        List cards = Queries.getCards();
        String[] cols = {"Expansion", "Num", "Carta", "Senda"};
        String[][] rows = new String[cards.size()][4];
        int i = 0;
        jProgressBar.setMaximum(cards.size());
        Iterator cardIterator = cards.iterator();
        while (cardIterator.hasNext()) {
            Card card = (Card) cardIterator.next();
            rows[i][0] = card.getExpansion().getName();
            rows[i][1] = String.valueOf(card.getNumber());
            rows[i][2] = card.getName();
            rows[i][3] = card.getPathway().getName();
            i++;
            jProgressBar.setValue(i);
        }
        GenericTableModel tModel = new GenericTableModel(cols, rows);
        tableCards.setModel(tModel);
        tableCards.repaint();
        pbarCards.setValue(i);
        pbarCards.setString(i + "/360 Cartas Cargadas");
    }

    private void cleanForm() {
        txtName.setText("Nueva Carta");
        txtNumber.setText("");
        txtaEfect.setText("");
        txtaText.setText("");
        txtCost.setText("");
        txtFUE.setText("");
        txtRES.setText("");
        cboExpansion.setSelectedIndex(0);
        cboArtist1.setSelectedIndex(0);
        cboArtist2.setSelectedIndex(0);
        cboExpansion.setSelectedIndex(0);
        cboFrequency.setSelectedIndex(0);
        cboPathway.setSelectedIndex(0);
        cboType.setSelectedIndex(0);
        lstSubtypes.removeSelectionInterval(0, lstSubtypes.getModel().getSize());
        lstSupertypes.removeSelectionInterval(0, lstSupertypes.getModel().getSize());
        txtName.setSelectionStart(0);
        txtName.setSelectionEnd(txtName.getText().length());
        txtName.requestFocus();
    }

    private void disableAllTypeCaracteristics() {
        txtCost.setEnabled(false);
        txtFUE.setEnabled(false);
        txtRES.setEnabled(false);
        lstSubtypes.setEnabled(false);
        lstSupertypes.setEnabled(false);
        txtCost.setText("");
        txtFUE.setText("");
        txtRES.setText("");
        lstSubtypes.removeSelectionInterval(0, lstSubtypes.getModel().getSize());
        lstSupertypes.removeSelectionInterval(0, lstSupertypes.getModel().getSize());
    }

    private void disableButtons() {
        btnClean.setEnabled(false);
        btnRemoveCard.setEnabled(false);
        btnLoadCards.setEnabled(false);
        btnSave.setEnabled(false);
    }

    private void enableAllTypeCaracteristics() {
        txtCost.setEnabled(true);
        txtFUE.setEnabled(true);
        txtRES.setEnabled(true);
        lstSubtypes.setEnabled(true);
        lstSupertypes.setEnabled(true);
    }

    private void enableButtons() {
        btnClean.setEnabled(true);
        btnRemoveCard.setEnabled(true);
        btnLoadCards.setEnabled(true);
        btnSave.setEnabled(true);
    }

    private ArrayList getSelectedCards() throws NumberFormatException {
        ArrayList cards = new ArrayList();
        for (int row : tableCards.getSelectedRows()) {
            Expansion exp = new Expansion(tableCards.getModel().getValueAt(row, 0).toString());
            int num = Integer.parseInt((String) tableCards.getModel().getValueAt(row, 1));
            cards.add(Queries.getCard(exp, num));
        }

        return cards;
    }

    private void loadExpansions() {
        List expansions = Queries.getExpansions();
        cboExpansion.removeAllItems();
        for (int i = 0; expansions.size() > i; i++) {
            this.expansions.put(expansions.get(i).toString(),
                    (Expansion) expansions.get(i));
            cboExpansion.addItem(expansions.get(i));
        }
    }

    private void loadLists() {
        loadSupertypes();
        loadSubtypes();
    }

    private void loadCombos() {
        loadExpansions();
        loadTypes();
        loadPathways();
        loadFrequencies();
        loadFirstArtist();
    }

    private void loadFirstArtist() {
        List artists1 = Queries.getArtists();
        cboArtist1.removeAllItems();
        for (int i = 0; artists1.size() > i; i++) {
            this.artists.put(((Artist) artists1.get(i)).toString(),
                    (Artist) artists1.get(i));
            cboArtist1.addItem(artists1.get(i));
        }
    }

    private void loadFrequencies() {
        List frequencies = Queries.getFrequencies();
        cboFrequency.removeAllItems();
        for (int i = 0; frequencies.size() > i; i++) {
            this.frequencies.put(frequencies.get(i).toString(),
                    (Frequency) frequencies.get(i));
            cboFrequency.addItem(frequencies.get(i));
        }
    }

    private void loadPathways() {
        List pathways = Queries.getPathways();
        cboPathway.removeAllItems();
        for (int i = 0; pathways.size() > i; i++) {
            this.pathways.put(pathways.get(i).toString(),
                    (Pathway) pathways.get(i));
            cboPathway.addItem(pathways.get(i));
        }
    }

    private void loadSecondArtist() {
        List artists2 = Queries.getArtists();
        cboArtist2.removeAllItems();
        cboArtist2.addItem("[No Seleccionado]");
        for (int i = 0; artists2.size() > i; i++) {
            if (((Artist) artists2.get(i)).getId() == ((Artist) cboArtist1.getSelectedItem()).getId()) {
                continue;
            }
            cboArtist2.addItem(artists2.get(i));
        }
    }

    private void loadTypes() {
        List types = Queries.getTypes();
        cboType.removeAllItems();
        for (int i = 0; types.size() > i; i++) {
            this.types.put(types.get(i).toString(),
                    (Type) types.get(i));
            cboType.addItem(types.get(i));
        }
    }

    private void loadSubtypes() {
        List subtypes = Queries.getSubtypes();
        lstSubtypes.removeAll();
        DefaultListModel listModel = new DefaultListModel();
        for (int i = 0; subtypes.size() > i; i++) {
            this.subtypes.put(subtypes.get(i).toString(),
                    (Subtype) subtypes.get(i));
            listModel.addElement(subtypes.get(i));
        }
        lstSubtypes.setModel(listModel);
    }

    private void loadSupertypes() {
        List supertypes = Queries.getSupertypes();
        lstSupertypes.removeAll();
        DefaultListModel listModel = new DefaultListModel();
        for (int i = 0; supertypes.size() > i; i++) {
            this.supertypes.put(supertypes.get(i).toString(),
                    (Supertype) supertypes.get(i));
            listModel.addElement(supertypes.get(i));
        }
        lstSupertypes.setModel(listModel);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane = new javax.swing.JTabbedPane();
        pnlDatabase = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tableCards = new javax.swing.JTable();
        btnRemoveCard = new javax.swing.JButton();
        btnLoadCards = new javax.swing.JButton();
        pbarCards = new javax.swing.JProgressBar();
        pnlNewCard = new javax.swing.JPanel();
        lblName = new javax.swing.JLabel();
        lblEfect = new javax.swing.JLabel();
        txtName = new javax.swing.JTextField();
        cboType = new javax.swing.JComboBox();
        lblType = new javax.swing.JLabel();
        lblText = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        txtaEfect = new javax.swing.JTextArea();
        jScrollPane3 = new javax.swing.JScrollPane();
        txtaText = new javax.swing.JTextArea();
        btnSave = new javax.swing.JButton();
        btnClean = new javax.swing.JButton();
        lblPathway = new javax.swing.JLabel();
        cboPathway = new javax.swing.JComboBox();
        lblFrequency = new javax.swing.JLabel();
        cboFrequency = new javax.swing.JComboBox();
        lblArtist1 = new javax.swing.JLabel();
        lblArtist2 = new javax.swing.JLabel();
        cboArtist1 = new javax.swing.JComboBox();
        cboArtist2 = new javax.swing.JComboBox();
        pnlAliado = new javax.swing.JPanel();
        lblSupertypes = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        lstSupertypes = new javax.swing.JList();
        lblSubtypes = new javax.swing.JLabel();
        jScrollPane5 = new javax.swing.JScrollPane();
        lstSubtypes = new javax.swing.JList();
        lblCost = new javax.swing.JLabel();
        lblStr = new javax.swing.JLabel();
        lblRes = new javax.swing.JLabel();
        txtCost = new javax.swing.JTextField();
        txtFUE = new javax.swing.JTextField();
        txtRES = new javax.swing.JTextField();
        lblExpnasion = new javax.swing.JLabel();
        cboExpansion = new javax.swing.JComboBox();
        lblNumber = new javax.swing.JLabel();
        txtNumber = new javax.swing.JTextField();
        jProgressBar = new javax.swing.JProgressBar();
        btnHelp = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Editor de Base de Datos 1.3.1 - Drecker 2.0 ");
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        tableCards.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Expansion", "Num", "Carta", "Senda"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tableCards.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tableCardsKeyTyped(evt);
            }
        });
        jScrollPane1.setViewportView(tableCards);

        btnRemoveCard.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/16/delete.png"))); // NOI18N
        btnRemoveCard.setText("Borrar Carta");
        btnRemoveCard.setToolTipText("Borrar la Carta Seleccionada");
        btnRemoveCard.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRemoveCardActionPerformed(evt);
            }
        });

        btnLoadCards.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/16/database_refresh.png"))); // NOI18N
        btnLoadCards.setText("Actualizar Cartas");
        btnLoadCards.setToolTipText("Volver a pedir datos a la Base de Datos.");
        btnLoadCards.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLoadCardsActionPerformed(evt);
            }
        });

        pbarCards.setMaximum(360);
        pbarCards.setToolTipText("Cantidad de Cartas Cargadas");
        pbarCards.setStringPainted(true);

        javax.swing.GroupLayout pnlDatabaseLayout = new javax.swing.GroupLayout(pnlDatabase);
        pnlDatabase.setLayout(pnlDatabaseLayout);
        pnlDatabaseLayout.setHorizontalGroup(
            pnlDatabaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatabaseLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDatabaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 501, Short.MAX_VALUE)
                    .addGroup(pnlDatabaseLayout.createSequentialGroup()
                        .addComponent(btnLoadCards)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pbarCards, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnRemoveCard)))
                .addContainerGap())
        );
        pnlDatabaseLayout.setVerticalGroup(
            pnlDatabaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlDatabaseLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatabaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(btnRemoveCard, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnLoadCards, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pbarCards, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        jTabbedPane.addTab("Base de Datos", pnlDatabase);

        pnlNewCard.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        lblName.setText("Nombre:");

        lblEfect.setText("Efecto:");

        txtName.setText("Nueva Carta");
        txtName.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtNameKeyTyped(evt);
            }
        });

        cboType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cboType.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cboTypeActionPerformed(evt);
            }
        });

        lblType.setText("Tipo:");

        lblText.setText("Texto:");

        txtaEfect.setColumns(20);
        txtaEfect.setLineWrap(true);
        txtaEfect.setRows(5);
        jScrollPane2.setViewportView(txtaEfect);

        txtaText.setColumns(20);
        txtaText.setLineWrap(true);
        txtaText.setRows(5);
        jScrollPane3.setViewportView(txtaText);

        btnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/16/accept.png"))); // NOI18N
        btnSave.setText("Registrar");
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });

        btnClean.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/16/textfield.png"))); // NOI18N
        btnClean.setText("Limpiar");
        btnClean.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCleanActionPerformed(evt);
            }
        });

        lblPathway.setText("Senda:");

        cboPathway.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        lblFrequency.setText("Frequencia:");

        cboFrequency.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        lblArtist1.setText("Artista 1:");

        lblArtist2.setText("Artista 2:");

        cboArtist1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cboArtist1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cboArtist1ActionPerformed(evt);
            }
        });

        cboArtist2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        pnlAliado.setBorder(javax.swing.BorderFactory.createTitledBorder("Características del Tipo:"));

        lblSupertypes.setText("Super-Tipos:");

        lstSupertypes.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane4.setViewportView(lstSupertypes);

        lblSubtypes.setText("Sub-Tipos:");

        lstSubtypes.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane5.setViewportView(lstSubtypes);

        lblCost.setText("Coste:");

        lblStr.setText("FUE:");

        lblRes.setText("RES:");

        javax.swing.GroupLayout pnlAliadoLayout = new javax.swing.GroupLayout(pnlAliado);
        pnlAliado.setLayout(pnlAliadoLayout);
        pnlAliadoLayout.setHorizontalGroup(
            pnlAliadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlAliadoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlAliadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblSupertypes)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(pnlAliadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(pnlAliadoLayout.createSequentialGroup()
                        .addComponent(lblSubtypes)
                        .addGap(78, 78, 78)
                        .addComponent(lblCost))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlAliadoLayout.createSequentialGroup()
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(pnlAliadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(lblStr)
                            .addComponent(lblRes))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlAliadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtRES, 0, 0, Short.MAX_VALUE)
                    .addComponent(txtFUE, 0, 0, Short.MAX_VALUE)
                    .addComponent(txtCost, javax.swing.GroupLayout.DEFAULT_SIZE, 37, Short.MAX_VALUE))
                .addGap(314, 314, 314))
        );
        pnlAliadoLayout.setVerticalGroup(
            pnlAliadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlAliadoLayout.createSequentialGroup()
                .addGroup(pnlAliadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblSupertypes)
                    .addComponent(lblSubtypes)
                    .addComponent(lblCost)
                    .addComponent(txtCost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlAliadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlAliadoLayout.createSequentialGroup()
                        .addGroup(pnlAliadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblStr)
                            .addComponent(txtFUE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlAliadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblRes)
                            .addComponent(txtRES, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
                .addContainerGap())
        );

        lblExpnasion.setText("Expansión:");

        cboExpansion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        lblNumber.setText("Número:");

        javax.swing.GroupLayout pnlNewCardLayout = new javax.swing.GroupLayout(pnlNewCard);
        pnlNewCard.setLayout(pnlNewCardLayout);
        pnlNewCardLayout.setHorizontalGroup(
            pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlNewCardLayout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(pnlNewCardLayout.createSequentialGroup()
                        .addComponent(btnSave)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnClean))
                    .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlNewCardLayout.createSequentialGroup()
                            .addGap(10, 10, 10)
                            .addComponent(pnlAliado, 0, 481, Short.MAX_VALUE))
                        .addGroup(pnlNewCardLayout.createSequentialGroup()
                            .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(pnlNewCardLayout.createSequentialGroup()
                                    .addGap(16, 16, 16)
                                    .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(lblEfect)
                                        .addComponent(lblText))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)
                                        .addComponent(jScrollPane2, 0, 0, Short.MAX_VALUE)))
                                .addGroup(pnlNewCardLayout.createSequentialGroup()
                                    .addGap(10, 10, 10)
                                    .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(lblName)
                                        .addComponent(lblNumber))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(txtName, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE)
                                        .addComponent(txtNumber, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlNewCardLayout.createSequentialGroup()
                                    .addGap(29, 29, 29)
                                    .addComponent(lblPathway))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlNewCardLayout.createSequentialGroup()
                                    .addGap(5, 5, 5)
                                    .addComponent(lblExpnasion))
                                .addGroup(pnlNewCardLayout.createSequentialGroup()
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblType))
                                .addComponent(lblFrequency)
                                .addGroup(pnlNewCardLayout.createSequentialGroup()
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblArtist1))
                                .addGroup(pnlNewCardLayout.createSequentialGroup()
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblArtist2)))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(cboType, 0, 140, Short.MAX_VALUE)
                                .addComponent(cboPathway, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(cboExpansion, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(cboFrequency, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(cboArtist1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(cboArtist2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
                .addContainerGap(24, Short.MAX_VALUE))
        );
        pnlNewCardLayout.setVerticalGroup(
            pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlNewCardLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlNewCardLayout.createSequentialGroup()
                        .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblName, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblNumber))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblEfect)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblText)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(pnlNewCardLayout.createSequentialGroup()
                        .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblExpnasion)
                            .addComponent(cboExpansion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblPathway)
                            .addComponent(cboPathway, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblType)
                            .addComponent(cboType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblFrequency)
                            .addComponent(cboFrequency, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblArtist1)
                            .addComponent(cboArtist1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblArtist2)
                            .addComponent(cboArtist2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlAliado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlNewCardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnSave)
                    .addComponent(btnClean))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane.addTab("Carta", pnlNewCard);

        jProgressBar.setStringPainted(true);

        btnHelp.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/16/help.png"))); // NOI18N
        btnHelp.setToolTipText("Creditos");
        btnHelp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnHelpActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jProgressBar, javax.swing.GroupLayout.DEFAULT_SIZE, 483, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnHelp)
                .addContainerGap())
            .addComponent(jTabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jTabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 424, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnHelp)))
        );

        pack();
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        java.awt.Dimension dialogSize = getSize();
        setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
    }// </editor-fold>//GEN-END:initComponents

    private void txtNameKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNameKeyTyped
        if (txtName.getText().length() == 0) {
            txtName.setBackground(Color.red);
        } else {
            txtName.setBackground(Color.white);
        }
    }//GEN-LAST:event_txtNameKeyTyped

    private void btnCleanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCleanActionPerformed
        cleanForm();
        loadCombos();
    }//GEN-LAST:event_btnCleanActionPerformed

    private void cboArtist1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboArtist1ActionPerformed
        if (cboArtist1.getSelectedIndex() >= 0) {
            loadSecondArtist();
        }
    }//GEN-LAST:event_cboArtist1ActionPerformed

private void cboTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboTypeActionPerformed
    if (cboType.getSelectedIndex() < 0) {
        return;
    }

    if (((Type) cboType.getSelectedItem()).getName().compareToIgnoreCase("Aliado") == 0) {
        enableAllTypeCaracteristics();
    } else if (((Type) cboType.getSelectedItem()).getName().compareToIgnoreCase("Arma") == 0) {
        enableAllTypeCaracteristics();
        lstSubtypes.setEnabled(false);
    } else if (((Type) cboType.getSelectedItem()).getName().compareToIgnoreCase("Ritual") == 0
            || ((Type) cboType.getSelectedItem()).getName().compareToIgnoreCase("Objeto") == 0) {
        disableAllTypeCaracteristics();
        txtCost.setEnabled(true);
        lstSupertypes.setEnabled(true);
    } else {
        disableAllTypeCaracteristics();
    }
}//GEN-LAST:event_cboTypeActionPerformed

private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
    if (!validateFields()) {
        return;
    }

    Card newCard = new Card(txtName.getText());
    newCard.setNumber(Integer.parseInt(txtNumber.getText()));
    newCard.setEffect(txtaEfect.getText());
    newCard.setText(txtaText.getText());
    newCard.setCost(txtCost.getText());
    newCard.setStr(txtFUE.getText());
    newCard.setRes(txtRES.getText());
    newCard.setExpansion((Expansion) cboExpansion.getSelectedItem());
    newCard.setFrequency((Frequency) cboFrequency.getSelectedItem());
    newCard.setPathway((Pathway) cboPathway.getSelectedItem());
    List artists = new ArrayList();
    artists.add((Artist) cboArtist1.getSelectedItem());
    if (cboArtist2.getSelectedIndex() > 0) {
        artists.add((Artist) cboArtist2.getSelectedItem());
    }
    newCard.setArtist(artists);
    List type = new ArrayList();
    type.add((Type) cboType.getSelectedItem());
    List superTypes = new ArrayList();
    for (int i = 0; lstSupertypes.getSelectedValues().length > i; i++) {
        superTypes.add((Supertype) lstSupertypes.getModel().
                getElementAt(lstSupertypes.getSelectedIndices()[i]));
    }
    newCard.setSupertype(superTypes);
    List subTypes = new ArrayList();
    for (int i = 0; lstSubtypes.getSelectedValues().length > i; i++) {
        subTypes.add((Subtype) lstSubtypes.getModel().
                getElementAt(lstSubtypes.getSelectedIndices()[i]));
    }
    newCard.setSubtype(subTypes);
    newCard.setType(type);

    if (Queries.save(newCard)) {
        JOptionPane.showMessageDialog(this, "La carta " + newCard.getName()
                + " se guardo correctamente.", "Resultado de la Operacion",
                JOptionPane.INFORMATION_MESSAGE);
        cleanForm();
    } else {
        JOptionPane.showMessageDialog(this, "La carta " + newCard.getName()
                + " no se pudo guardar.", "Resultado de la Operacion",
                JOptionPane.WARNING_MESSAGE);
    }

    loadTable();
}//GEN-LAST:event_btnSaveActionPerformed

private void btnRemoveCardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveCardActionPerformed
    if (tableCards.getSelectedRow() < 0) {
        return;
    }
    ArrayList selectedCard = getSelectedCards();
    for (Object card : selectedCard.toArray()) {
        Queries.remove((Card) card);
    }
    loadTable();
}//GEN-LAST:event_btnRemoveCardActionPerformed

private void tableCardsKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tableCardsKeyTyped
    //if (evt.getKeyCode() == Character.)
}//GEN-LAST:event_tableCardsKeyTyped

private void btnLoadCardsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoadCardsActionPerformed
    this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    disableButtons();
    loadTable();
    enableButtons();
    this.setCursor(null);
}//GEN-LAST:event_btnLoadCardsActionPerformed

private void btnHelpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHelpActionPerformed
    JOptionPane.showMessageDialog(this, "Editor de Bases de Datos v1.3.1\n"
            + "Este editor fue creado exclusivamente para la base de datos\n"
            + "de \"Drecker, el creador de mazos v2.0\".\n"
            + "Drecker 2.0 y su Editor de Bases de Datos se encuentran\n"
            + "licenciados bajo GPL V3.\n\n"
            + "Autor:\n"
            + "Carlos S. Moreno - carloss.moreno@gmail.com",
            "Créditos y Licencia", JOptionPane.INFORMATION_MESSAGE);
}//GEN-LAST:event_btnHelpActionPerformed

private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
    JOptionPane.showMessageDialog(this, "El editor va a conectarse a la base de datos remota.\n"
            + "Esto puede demorar unos minutos, dependiendo de tu conexion a Internet.",
            "Conexion Remota", JOptionPane.INFORMATION_MESSAGE);
    this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    disableButtons();
    loadCombos();
    loadLists();
    loadCVSFile("despertar.csv");    
    loadCVSFile("insania.csv");    
    loadTable();
    enableButtons();
    this.setCursor(null);
}//GEN-LAST:event_formWindowOpened

    private boolean validateFields() throws HeadlessException {
        boolean result = true;
        if (txtName.getText().compareToIgnoreCase("") == 0) {
            JOptionPane.showMessageDialog(this, "Debes ingresar un nombre a la carta!",
                    "Formulario Incompleto", JOptionPane.OK_OPTION);
            txtName.requestFocus();
            result = false;
        } else if (txtNumber.getText().compareToIgnoreCase("") == 0) {
            JOptionPane.showMessageDialog(this, "Debes ingresar un numero a la carta!",
                    "Formulario Incompleto", JOptionPane.OK_OPTION);
            txtNumber.requestFocus();
            result = false;
        } else if (txtCost.isEnabled()
                && txtCost.getText().compareToIgnoreCase("") == 0) {
            JOptionPane.showMessageDialog(this, "Debes ingresar un costo a la carta!",
                    "Formulario Incompleto", JOptionPane.OK_OPTION);
            txtCost.requestFocus();
            result = false;
        } else if (txtFUE.isEnabled()
                && txtFUE.getText().compareToIgnoreCase("") == 0) {
            JOptionPane.showMessageDialog(this, "Debes ingresar FUE a la carta!",
                    "Formulario Incompleto", JOptionPane.OK_OPTION);
            txtFUE.requestFocus();
            result = false;
        } else if (txtRES.isEnabled()
                && txtRES.getText().compareToIgnoreCase("") == 0) {
            JOptionPane.showMessageDialog(this, "Debes ingresar RES a la carta!",
                    "Formulario Incompleto", JOptionPane.OK_OPTION);
            txtRES.requestFocus();
            result = false;
        }

        try {
            Integer.getInteger(txtNumber.getText());
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Debes ingresar un numero valido a la carta!",
                    "Formulario Incompleto", JOptionPane.OK_OPTION);
            txtNumber.requestFocus();
            result = false;
        }
        return result;
    }

    private void loadCVSFile(String file) {
        FileInputStream dataIn;
        try {
            
            Archive archive = new Archive(file);
            
            String data_str = "";

            /*while (data.available() > 0) {
            data_str += data.
            }*/
            data_str = archive.readString();
            String data_array[] = data_str.split("\n");

            /*for (int i=0;i<data_array.length; i++) {
            System.out.println(data_array[i]);
            }*/

            //File set = new File("yvd.set");
            //FileOutputStream dataOut = new FileOutputStream("yvd.set");
            //DataOutputStream data2 = new DataOutputStream(dataOut);
            String entrada = "";
            Card card = null;
            for (int i = 0; i < data_array.length; i++) {
                String[] valores = data_array[i].split(";");
                card = new Card(valores[1]);
                card.setNumber(Integer.parseInt(valores[0]));
                card.setPathway(pathways.get(valores[2]));
                if (card.getPathway() == null)
                    System.out.println("");
                card.setFrequency(frequencies.get(valores[9]));
                card.setExpansion(expansions.get(valores[11]));
                card.setCost(valores[4]);
                card.setStr(valores[7]);
                card.setRes(valores[8]);
                card.setEffect(valores[6]);
                card.setText(valores[10]);
                //Getting Artists
                if (valores.length > 12) {
                    card.getArtist().add(artists.get(valores[12]));
                }
                if (valores.length > 13) {
                    card.getArtist().add(artists.get(valores[13]));
                }
                //Getting Types
                String[] types = valores[5].split(" ");
                for (String type : types) {
                    type = type.substring(0, 1).toUpperCase() + type.substring(1);
                    //type = type.replace("\"", "");
                    if (this.types.get(type) != null) {
                        card.getType().add(this.types.get(type));
                    } else if (this.supertypes.get(type) != null) {
                        card.getSupertype().add(this.supertypes.get(type));
                    }
                }
                if (valores[3].compareToIgnoreCase("") != 0) {
                    String[] subtypes = valores[3].split(" ");
                    for (String subtype : subtypes) {
                        subtype = subtype.substring(0, 1).toUpperCase() + subtype.substring(1);
                        if (this.subtypes.get(subtype) != null) {
                            card.getSubtype().add(this.subtypes.get(subtype));
                        }
                    }
                }
                //System.out.println(card);
                if (Queries.save(card))
                    System.out.println(card.getNumber() + " Saved.\n");;
            }
            //data2.writeUTF(entrada);
            //data2.flush();
        } catch (Exception ex) {
            System.out.println("WTF??: " + ex.getMessage() + " " + ex.getLocalizedMessage());
            ex.printStackTrace();
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {

        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(dbEditor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(dbEditor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(dbEditor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(dbEditor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>


        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                try {
                    new dbEditor().setVisible(true);
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null,
                            "Error: " + e.getMessage(),
                            "Error al Iniciar", JOptionPane.ERROR_MESSAGE);
                }
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnClean;
    private javax.swing.JButton btnHelp;
    private javax.swing.JButton btnLoadCards;
    private javax.swing.JButton btnRemoveCard;
    private javax.swing.JButton btnSave;
    private javax.swing.JComboBox cboArtist1;
    private javax.swing.JComboBox cboArtist2;
    private javax.swing.JComboBox cboExpansion;
    private javax.swing.JComboBox cboFrequency;
    private javax.swing.JComboBox cboPathway;
    private javax.swing.JComboBox cboType;
    private javax.swing.JProgressBar jProgressBar;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JTabbedPane jTabbedPane;
    private javax.swing.JLabel lblArtist1;
    private javax.swing.JLabel lblArtist2;
    private javax.swing.JLabel lblCost;
    private javax.swing.JLabel lblEfect;
    private javax.swing.JLabel lblExpnasion;
    private javax.swing.JLabel lblFrequency;
    private javax.swing.JLabel lblName;
    private javax.swing.JLabel lblNumber;
    private javax.swing.JLabel lblPathway;
    private javax.swing.JLabel lblRes;
    private javax.swing.JLabel lblStr;
    private javax.swing.JLabel lblSubtypes;
    private javax.swing.JLabel lblSupertypes;
    private javax.swing.JLabel lblText;
    private javax.swing.JLabel lblType;
    private javax.swing.JList lstSubtypes;
    private javax.swing.JList lstSupertypes;
    private javax.swing.JProgressBar pbarCards;
    private javax.swing.JPanel pnlAliado;
    private javax.swing.JPanel pnlDatabase;
    private javax.swing.JPanel pnlNewCard;
    private javax.swing.JTable tableCards;
    private javax.swing.JTextField txtCost;
    private javax.swing.JTextField txtFUE;
    private javax.swing.JTextField txtName;
    private javax.swing.JTextField txtNumber;
    private javax.swing.JTextField txtRES;
    private javax.swing.JTextArea txtaEfect;
    private javax.swing.JTextArea txtaText;
    // End of variables declaration//GEN-END:variables
}
